package com.ruipengkj.view.workShiftView;

import java.awt.BorderLayout;
import java.awt.CardLayout;
import java.awt.event.ActionEvent;

import javax.swing.JButton;
import javax.swing.JPanel;
import javax.swing.JToolBar;

import com.ruipengkj.commons.util.SwingUtil;
import com.ruipengkj.commons.util.Util;
import com.ruipengkj.view.base.BaseInternalFrame;

public class WorkShiftInternalFrame extends BaseInternalFrame{

	private static final long serialVersionUID = 1L;
	
	private JToolBar toolBar;
	
	private JPanel main;
	private CardLayout main_layout;
	
	private JButton workShiftButton;
	private WorkShiftPanel workShiftPanel;
	

	public WorkShiftInternalFrame(String title, boolean resizable,boolean closable, boolean maximizable, boolean iconifiable) {
		super(title, resizable, closable, maximizable, iconifiable);
		this.init();
	}

	private void init() {
		this.initView();
		this.initListener();
	}

	private void initView() {
		toolBar = new JToolBar();
		toolBar.setFloatable(false);
		
		workShiftButton = new JButton("交班",SwingUtil.getOpenSwingImage("member_card_the issuing.png"));
//		if(ApplicationContext.TRIGHT_LIST.contains(ApplicationContext.RIGHT_LIVEL101)){
//			toolBar.add(workShiftButton);
//		}
//		
		main=new JPanel();
		main_layout=new CardLayout();
		main.setLayout(main_layout);
		this.add(toolBar,BorderLayout.NORTH);
		this.add(main,BorderLayout.CENTER);
	}
	
	private void initListener() {
		workShiftButton.addActionListener(this);
	}
	
	@Override
	public void actionPerformed(ActionEvent e){
		if(e.getSource()==workShiftButton){
			workShiftPanel = new WorkShiftPanel();
			main.add(workShiftPanel,"workShiftPanel");
			main_layout.show(main, "workShiftPanel");
			this.setTitle("交班信息--交班");
			Util.setButtonStatus(toolBar,workShiftButton);
		}
		main.updateUI();
	}
	
	public void showButton(){
		if (toolBar != null && toolBar.getComponentCount() != 0)
			((JButton)toolBar.getComponent(0)).doClick();
	}
	
	public void showButton(int type){
		switch(type){
			case 1:{workShiftButton.doClick();break;}
		}
	}

}
